package com.qqt.util;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.ResourceBundle;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.qqt.wx.controller.WeixinController;

public class Parameters {
    private static final Logger logger = LoggerFactory.getLogger(Parameters.class);
	public static String getProperty(String key, String defaultValue) {
		ResourceBundle rb = ResourceBundle.getBundle("config");
		String tmp = rb.getString(key);
		return StringUtils.isBlank(tmp)?defaultValue:tmp.trim();
	}

	public static int getProperty(String key, int defaultValue) {
		ResourceBundle rb = ResourceBundle.getBundle("config");
		try{
			String tmp = rb.getString(key);
			return StringUtils.isBlank(tmp)?defaultValue:Integer.parseInt(tmp);
		}catch(Exception e){
			logger.error("配置文件解析失败",e);
			return defaultValue;
		}
	}

	public static boolean getProperty(String key, boolean defaultValue) {
		ResourceBundle rb = ResourceBundle.getBundle("config");
		try{
			String tmp = rb.getString(key);
			return StringUtils.isBlank(tmp)?defaultValue:Boolean.parseBoolean(tmp);
		}catch(Exception e){
			logger.error("配置文件解析失败",e);
			return defaultValue;
		}
	}
	
}
